<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="classid" :rules="rules" label-width="100px" id="mvcfm">
      <el-button @click="cate('&CMID='+scope.row.parent_id+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回上一级</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 分类列表 </span>
      </div>
      <el-table :data="classid">
        <el-table-column label="操作" align="center" width='100' type=''>
          <template slot-scope="scope">
            <el-dropdown trigger="click">
              <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>
                  <el-link @click="gotoPage('/oa/communication/MesPhraseCateUp?CMID4='+scope.row.category_id+''+vueparams+'')">修改</el-link>
                </el-dropdown-item>
                <el-dropdown-item>
                  <el-link @click="d_class('&category_id='+scope.row.category_id+'')">删除</el-link>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
        <el-table-column label="分类名" prop="category_id">
          <template slot-scope="scope">
            <el-link @click="gotoPage('/oa/communication/CommonSms?CMID='+scope.row.category_id+''+vueparams+'')" type='primary'>{{scope.row.category_name}}</el-link>
          </template>
        </el-table-column>
      </el-table>
      <el-button @click="popMesPhraseCateAdd('')" type='success' size="mini"><i class='fa fa-plus'></i>增加类别</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 短信内容 </span>
      </div>
      <el-table :data="content">
        <el-table-column label="操作" align="center" width='100' type=''>
          <template slot-scope="scope">
            <el-dropdown trigger="click">
              <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>
                  <el-link @click="d_content('&CMID3='+scope.row.content_id+'')">删除</el-link>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
        <el-table-column label="短信内容" prop="content_id">
          <template slot-scope="scope">
            <el-link @click="gotoPage('/oa/communication/MesPhraseDetailed?CMID3='+scope.row.content_id+''+vueparams+'')" type='primary'>{{scope.row.content_des}}</el-link>
          </template>
        </el-table-column>
      </el-table>
      <el-button @click="popMesDesAdd('')" type='success' size="mini"><i class='fa fa-plus'></i>增加常用短息</el-button>
    </el-form>
    <el-dialog :visible.sync="MesPhraseCateAddVisible" append-to-body>
      <MesPhraseCateAdd v-if="MesPhraseCateAddVisible" ref="MesPhraseCateAdd" :popparams="popparams"> </MesPhraseCateAdd>
    </el-dialog>
    <el-dialog :visible.sync="MesDesAddVisible" append-to-body>
      <MesDesAdd v-if="MesDesAddVisible" ref="MesDesAdd" :popparams="popparams"> </MesDesAdd>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import MesPhraseCateAdd from "@/views/oa/communication/MesPhraseCateAdd";
  import MesDesAdd from "@/views/oa/communication/MesDesAdd";
  export default {
    name: 'CommonSms',
    components: {
      MesPhraseCateAdd,
      MesDesAdd,
    },
    props: ['popparams'],
    data() {
      return {
        MesPhraseCateAddVisible: false,
        MesPhraseCateAddValue: null,
        MesPhraseCateAddDesc: null,
        MesDesAddVisible: false,
        MesDesAddValue: null,
        MesDesAddDesc: null,
        vueparams: this.getVUEParams(""),
        classid: [],
        content: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/oa/communication/SmsAction/commonSms?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_content(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/oa/communication/SmsAction/d_content?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_class(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/oa/communication/SmsAction/d_class?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popMesPhraseCateAdd(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.MesPhraseCateAddVisible = !this.MesPhraseCateAddVisible;
      },
      popMesDesAdd(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.MesDesAddVisible = !this.MesDesAddVisible;
      },
    },
  }
</script>
